/**
 * Copyright(c) 2014 Xunton Solutions
 *
 * History:
 *   15-9-28 下午4:41 Created by dwzhang
 */
package com.jade.bss.weixin.api.user;

import javax.inject.Named;

import com.jade.bss.weixin.WeixinException;
import com.jade.bss.weixin.api.protocol.json.JsonApi;
import com.jade.bss.weixin.api.user.protocol.OpenIdList;
import com.jade.bss.weixin.api.user.protocol.UserInfo;

import java.util.List;

/**
 * 用户接口。
 *
 * @author <a href="mailto:dwzhang@xunton.com">dwzhang</a> 
 * @version 1.0 15-9-28 下午4:41
 */
@Named ("bss_weixinUserApi")
public class UserApi
        extends JsonApi
{
    public static final String URL_GET_USERLIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token=";
    public static final String URL_GET_USERINFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=";
//  public static final String URL_GET_USERINFO = "https://api.weixin.qq.com/sns/userinfo?access_token=";

    public OpenIdList getUserList(String accessToken, String openId) throws Exception
    {
        String url = URL_GET_USERLIST + accessToken + "&next_openid=" + openId;
        return get(url, OpenIdList.class);
    }

    public UserInfo getUserInfo(String accessToken, String openId)
            throws WeixinException
    {
        String url = URL_GET_USERINFO + accessToken + "&openid=" + openId + "&lang=zh_CN";
        return get(url, UserInfo.class);
    }
}
